<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/common/inner-header.jspf"%>
<title>密码修改</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/static/common/plugin/nice-validator-0.8.1/jquery.validator.css">
<script type="text/javascript" src="<%=request.getContextPath()%>/static/common/plugin/nice-validator-0.8.1/jquery.validator.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/common/plugin/nice-validator-0.8.1/local/zh-CN.js"></script>

         <form method="post"  action="<%=request.getContextPath()%>/CommonServlet?command=modifyPassword" >
           原密码：<input name="oldpassword" id="oldpassword" type="text" onblur="validateOldpassword(this)"/><span id="oldpwd"></span><br>
           输入新密码：<input type="password" name="user[pwd]" data-rule="密码: required;password;"/><br>
           再输入一次：<input type="password" name="againPwd" data-rule="确认密码: required;match(user[pwd]);" value=""/><br>
       <button type="submit" class="btn btn-default">确认修改</button>
              </form>
     <script>
     function validateOldpassword(oldpassword) {
		var oldpassword = document.getElementById("oldpassword").value;
			//1,创建XMLHttpRwquest对象
			var xmlhttp;
			if(window.XMLHttpRequest){
				xmlhttp = new XMLHttpRequest();
			}else{
				xmlhttp = ActiveXObject("Microsoft.XMLHTTP");
			}
			//2.指定XMLhttpRequest的到达地址及到达方式 
			xmlhttp.open("post","<%=request.getContextPath()%>/CommonServlet?command=lookupPassword&oldpassword="+ oldpassword ,true);
			//3.XMLhttpRequest发送
			xmlhttp.send();
			//4.响应结果
			xmlhttp.onreadystatechange = function(){
		  if (xmlhttp.readyState==4 && xmlhttp.status==200){
			  var submitDOM = document.getElementById('submit');
			  var info = xmlhttp.responseText;
			
			  if(info=='　　　通过!'){
				  document.getElementById("oldpwd").innerHTML= info;
				    submitDOM.disabled = false;
			  }
			  else{
				  document.getElementById("oldpwd").innerHTML= info;
				    submitDOM.disabled =true; 
			  }
		  }
		}
     }
     </script>
